<?php include '../public/header.php' ?>
<?php include '../public/header_index.php' ?>
<body class="laytp-container">
<div id="opt_nav">
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">所属单位</label>
                        <div class="layui-input-block">
                            <div id="chanid" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">年份</label>
                        <div class="layui-input-block">
                            <input type="text" readonly id="year" name="year" placeholder="请选择" autocomplete="off" class="layui-input bdate_sea_y">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
    </div>
</script>
<script>




    var currButAuth, currTabData;
    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;


        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });

        setSouTableExport('主营业务支出报表');
        var mytable = table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_cai_zhi_tong),where: {}, page: false, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
            ,text: TabInit.text
            ,parseData: function (res) {
                currButAuth = res.data.butauth;
                tableButShow(currButAuth);

                xmselect_dan('chanid', res.data.chanid, res.data.is_chanid, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                })


                $("#year").val(res.data.year)
                $("#search-form").show()



                render_from();
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.total,
                    "data": res.data.data
                };
            }
            , cols: [[
                {type:'numbers',title:'序号'}
                ,{field: 'name', title: '成本科目'}
                ,{field:'year',title:'年度',align:'right'}
                ,{field:'count',title:'年度合计(元)',align:'right',templet: function(d){
                        return parseFormatNum(d.count);
                    }}
                ,{field:'mon1',title:'一月',align:'right',templet: function(d){
                        return '<span class="colorlan" onclick="account_zhi_func('+d.type+','+d.chanid+',\''+d.year+'-01\')">'+parseFormatNum(d.mon1)+'</span>';
                    }}
                ,{field:'mon2',title:'二月',align:'right',templet: function(d){
                        return '<span class="colorlan" onclick="account_zhi_func('+d.type+','+d.chanid+',\''+d.year+'-02\')">'+parseFormatNum(d.mon2)+'</span>';
                    }}
                ,{field:'mon3',title:'三月',align:'right',templet: function(d){
                        return '<span class="colorlan" onclick="account_zhi_func('+d.type+','+d.chanid+',\''+d.year+'-03\')">'+parseFormatNum(d.mon3)+'</span>';
                    }}
                ,{field:'mon4',title:'四月',align:'right',templet: function(d){
                        return '<span class="colorlan" onclick="account_zhi_func('+d.type+','+d.chanid+',\''+d.year+'-04\')">'+parseFormatNum(d.mon4)+'</span>';
                    }}
                ,{field:'mon5',title:'五月',align:'right',templet: function(d){
                        return '<span class="colorlan" onclick="account_zhi_func('+d.type+','+d.chanid+',\''+d.year+'-05\')">'+parseFormatNum(d.mon5)+'</span>';
                    }}
                ,{field:'mon6',title:'六月',align:'right',templet: function(d){
                        return '<span class="colorlan" onclick="account_zhi_func('+d.type+','+d.chanid+',\''+d.year+'-06\')">'+parseFormatNum(d.mon6)+'</span>';
                    }}
                ,{field:'mon7',title:'七月',align:'right',templet: function(d){
                        return '<span class="colorlan" onclick="account_zhi_func('+d.type+','+d.chanid+',\''+d.year+'-07\')">'+parseFormatNum(d.mon7)+'</span>';
                    }}
                ,{field:'mon8',title:'八月',align:'right',templet: function(d){
                        return '<span class="colorlan" onclick="account_zhi_func('+d.type+','+d.chanid+',\''+d.year+'-08\')">'+parseFormatNum(d.mon8)+'</span>';
                    }}
                ,{field:'mon9',title:'九月',align:'right',templet: function(d){
                        return '<span class="colorlan" onclick="account_zhi_func('+d.type+','+d.chanid+',\''+d.year+'-09\')">'+parseFormatNum(d.mon9)+'</span>';
                    }}
                ,{field:'mon10',title:'十月',align:'right',templet: function(d){
                        return '<span class="colorlan" onclick="account_zhi_func('+d.type+','+d.chanid+',\''+d.year+'-10\')">'+parseFormatNum(d.mon10)+'</span>';
                    }}
                ,{field:'mon11',title:'十一月',align:'right',templet: function(d){
                        return '<span class="colorlan" onclick="account_zhi_func('+d.type+','+d.chanid+',\''+d.year+'-11\')">'+parseFormatNum(d.mon11)+'</span>';
                    }}
                ,{field:'mon12',title:'十二月',align:'right',templet: function(d){
                        return '<span class="colorlan" onclick="account_zhi_func('+d.type+','+d.chanid+',\''+d.year+'-12\')">'+parseFormatNum(d.mon12)+'</span>';
                    }}
            ]]
            , done: function (res) {
                soulTable.render(this);

                currTabData = res.data;
            }
        });


        listTableSearch(form, table);
    });

    function account_zhi_func(type, chanid, yearmonth) {
        openPage('../account_zhi/tong.php?typedan='+type+'&chanid='+chanid+'&month='+encodeURI(yearmonth), '80%', '80%');
    }




</script>
</body>
</html>
